﻿using System;
using System.Threading;

namespace H.Net.Nets
{
    internal class BlockPointInfo : IDisposable
    {
        /// <summary>
        /// 当数据已经写入此上下文中时
        /// </summary>
        public AutoResetEvent WroteInBuffer { get; } = new AutoResetEvent(false);

        /// <summary>
        /// 当数据已经从此上下文中读取完毕时
        /// </summary>
        public AutoResetEvent ReadFromBuffer { get; } = new AutoResetEvent(true);

        /// <summary>
        /// 当前上下文中存储的数据
        /// </summary>
        public HWebFrame Frame { get; set; }


        public BlockPointInfo()
        {
        }


        public void Dispose(bool disposing)
        {
            if (disposing)
            {
                Frame = null;
            }
            WroteInBuffer.Dispose();
            ReadFromBuffer.Dispose();
        }

        public void Dispose()
        {
            Dispose(true);
        }

        ~BlockPointInfo()
        {
            Dispose(false);
        }
    }
}
